# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-mirage-net
_pkgname=mirage-net
pkgver=4.0.0
pkgrel=0
pkgdesc="Network signatures for MirageOS"
url="https://github.com/mirage/mirage-net"
arch="all !riscv64"  # limited by ocaml aport
license="ISC"
depends="
	ocaml-runtime
	ocaml-cstruct
	ocaml-lwt
	ocaml-ipaddr
	"
depends_dev="
	$pkgname=$pkgver-r$pkgrel
	ocaml-cstruct-dev
	ocaml-lwt-dev
	ocaml-ipaddr-dev
	"
makedepends="$depends_dev dune ocaml"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://github.com/mirage/mirage-net/releases/download/v$pkgver/mirage-net-v$pkgver.tbz"
builddir="$srcdir/$_pkgname-v$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
52064dc704ebd0d305fd234b6d89fc313d5a80016d8875ef93212a1962ad8b1f332f7b0338244afbb2d2f207a28d476e7d7639be9dc607d95145afee7fccc483  ocaml-mirage-net-4.0.0.tar.bz2
"
